package src.data;

//import org.hibernate.SessionFactory;
//import org.hibernate.cfg.AnnotationConfiguration;

import src.domain.IncomingMessage;
import src.domain.MailBox;
import src.domain.OutgoingMessage;
import src.domain.PostOffice;
import src.domain.User;
 
public class HibernateUtil
{
	private  static HibernateProvider provider;
	/*private static final SessionFactory sessionFactory;
	static
    {
        try
        {
        	 AnnotationConfiguration config = new AnnotationConfiguration();
           	 
             config.addAnnotatedClass(User.class);
             config.addAnnotatedClass(MailBox.class);
             config.addAnnotatedClass(PostOffice.class);
             config.addAnnotatedClass(IncomingMessage.class);
             config.addAnnotatedClass(OutgoingMessage.class);
             config.addAnnotatedClass(Message.class);
             
             sessionFactory = config.buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }*/
	
	
	public static void registerPersistent()
    {
        try
        {
        	provider=HibernateProvider.getInstance();
        	provider.registerPersistentClass(User.class);
        	provider.registerPersistentClass(MailBox.class);
        	provider.registerPersistentClass(PostOffice.class);
        	provider.registerPersistentClass(IncomingMessage.class);
        	provider.registerPersistentClass(OutgoingMessage.class);
        	
            
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
    
    /*public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }*/
 
}
